package cn.net.yato.picture.config;

import cn.net.yato.picture.util.log.MyPointcut;
import org.springframework.boot.web.server.ErrorPage;
import org.springframework.boot.web.server.ErrorPageRegistrar;
import org.springframework.boot.web.server.ErrorPageRegistry;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Component;

/**
 * @ClassName ErrorConfig
 * @Description TODO
 * @Author yato
 * @Date 2020/2/13 14:22
 * @Version 1.0
 */
@Component
public class ErrorConfig implements ErrorPageRegistrar {


    @MyPointcut
    @Override
    public void registerErrorPages(ErrorPageRegistry errorPageRegistry) {
        //页面状态码为404
        ErrorPage e404 = new ErrorPage(HttpStatus.NOT_FOUND, "/404.html");
        //页面状态码为500
        ErrorPage e500 = new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR, "/500.html");
        //页面状态码为403
        ErrorPage e403 = new ErrorPage(HttpStatus.FORBIDDEN, "/403.html");
        errorPageRegistry.addErrorPages(e404, e500,e403);
    }

}
